package com.situ.javase.week2.day3;

import javax.xml.stream.events.StartDocument;

import org.junit.Test;

public class StringHome {
	@Test   //第二题
	public void test1() {
		String str = "I Love Java！";
		char array[] = str.toCharArray();
		array[0] = 'I' + 32;
		array[2] = 'L' + 32;
		array[7] = 'J' + 32;
		for (int i = 0; i < array.length; i++) {
			System.out.print(array[i]);
		}
	}
	@Test
	public void test2() {
		String str = "I love Java!";
		System.out.println(str.toLowerCase());
	}
	
	@Test
	public void test3() {
		String str1 = "this is my homework! I must finish it!";
		String[] str2 = str1.split(" ");
		System.out.println(str2.length);
		
	}
	
	
	@Test
	public void test4() {
		String str = "   java Android   ";
		char array[] = str.toCharArray();
		int start = 0;
		int end = array.length;
		for (int i = 0; i < array.length; i++) {
			//System.out.print(array[i])
			if (array[i] == ' ') {
				start++;
				
			}else {
				break;
			}
			//System.out.println(start);
		}
		for (int i = array.length - 1; i >= 0; i--) {
			if (array[i] == ' ') {
				end--;
			}else {
				break;
			}
			//System.out.println(end);
		}
		System.out.println(str.substring(start, end));
	}
}

